<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/templates/mantenimiento.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                    
                xmlns:r="http://richfaces.org">
    <ui:define name="title">
        Administración de sistema
    </ui:define>    
    <ui:define name="datos">
        <center>
            <h:panelGrid id="panelDatos">
                <h:form id="formDatos">
                    <r:panel header="Datos" >
                        <h:panelGrid columns="4">
                            <h:graphicImage library="images/ajax" name="bullet.gif" />
                            <h:outputLabel for="clave" value="Clave:" />
                            <h:inputText id="clave" label="Clave"  size="50" maxlength="100" required="true" value="#{jsfSistema.object.clave}" />
                            <r:message for="clave" />

                            <h:graphicImage library="images/ajax" name="bullet.gif" />
                            <h:outputLabel for="nombre" value="Nombre:" />
                            <h:inputText id="nombre" label="Nombre"  size="50" maxlength="100" required="true" value="#{jsfSistema.object.nombre}" />
                            <r:message for="nombre" />

                            <h:graphicImage library="images/ajax" name="bullet.gif" />
                            <h:outputLabel for="contextPath" value="contexto:" />
                            <h:inputText id="contextPath" label="ContextPath"  size="50" maxlength="100" required="true" value="#{jsfSistema.object.contextPath}" />
                            <r:message for="contextPath" />

                            <f:verbatim />
                            <h:outputLabel for="url" value="Url:" />
                            <h:inputText id="url" label="Url"  size="50" maxlength="100" value="#{jsfSistema.object.host}" />
                            <r:message for="url" />

                            <f:verbatim/>
                            <h:outputLabel for="descripcion" value="Descripción:" />
                            <h:inputTextarea id="descripcion" label="Descripción" rows="3" cols="40" value="#{jsfSistema.object.descripcion}"/>
                            <r:message for="descripcion" />
                        </h:panelGrid>
                        <center>
                            <h:panelGrid >
                                <h:panelGroup id="panelBotones">
                                    <h:commandButton id="btGrabar" value="Grabar" action="#{jsfSistema.grabarAction}"  title="Grabar registro">
                                        <f:ajax execute="@form" event="action" render="commonStatus :panelDatos "/>
                                    </h:commandButton>
                                    <h:commandButton id="btNuevo" value="Nuevo" action="#{jsfSistema.nuevoAction}"  title="Limpiar o crear nuevo registro">
                                        <f:ajax event="action" render="@form"/>
                                    </h:commandButton>
                                    <r:status id="commonStatus">
                                        <f:facet name="start">
                                            <h:graphicImage library="images/ajax" name="status2.gif"/>
                                        </f:facet>
                                    </r:status>
                                </h:panelGroup>
                            </h:panelGrid>
                        </center>
                        <r:message for="formDatos">
                            <f:facet name="errorMarker">
                                <h:graphicImage library="images/ajax" name="warning.gif"/>
                            </f:facet>
                            <f:facet name="infoMarker">
                                <h:graphicImage library="images/ajax" name="passed.gif"/>
                            </f:facet>
                        </r:message>

                        <br />
                        <h:panelGroup >
                            <h:graphicImage library="images/ajax" name="bullet.gif" />
                            <h:outputText value="Campo obligatorio" styleClass="campo-obligatorio"/>
                        </h:panelGroup>
                        <div class="separador" />
                        <hr width="100%" />
                        <p /> 
                        <r:dataTable id="listaSimple" value="#{jsfSistema.lista}" var="item"  rows="20" rendered="#{jsfSistema.lista.size()>0}">
                            <f:facet name="header">
                                <h:outputText value="Registros encontrados [#{jsfSistema.lista.size()}]" />
                            </f:facet>
                            <h:column >
                                <f:facet name="header">
                                    <h:outputText value="#" />
                                </f:facet>
                                <h:outputText value="#{jsfSistema.lista.indexOf(item)+1}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText  value="Clave"/>
                                </f:facet>
                                <h:outputText value="#{item.clave}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText  value="Nombre"/>
                                </f:facet>
                                <h:outputText value="#{item.nombre}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText  value="path"/>
                                </f:facet>
                                <h:outputText value="#{item.contextPath}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText  value="Descripción"/>
                                </f:facet>
                                <h:outputText value="#{item.descripcion}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">
                                    <h:outputText value="Acción" />
                                </f:facet>
                                <h:commandLink action="#{jsfSistema.editarAction(item)}" title="Editar">
                                    <h:graphicImage library="images/icons" name="page-edit-icon-24.png" styleClass="pic" />
                                    <f:ajax execute="@this" event="action" render=":panelDatos"/>
                                </h:commandLink>
                                <h:commandLink action="#{jsfSistema.eliminarAction(item)}" title="Eliminar" onclick="if (!confirm('Seguro que desea eliminar el registro?')) {
                                            formLista.reset();
                                            return false;
                                        }">
                                    <h:graphicImage library="images/icons" name="Document-Delete-icon-24.png" styleClass="pic" />
                                    <f:ajax execute="@this" event="action" render="@form :panelDatos"/>
                                </h:commandLink>
                            </h:column>
                            <f:facet name="footer">
                                <h:panelGrid rendered="#{jsfSistema.lista.size()>20}">
                                    <r:dataScroller for="listaSimple" fastStep="10" render="commonStatus" />
                                </h:panelGrid>
                            </f:facet>
                        </r:dataTable>
                        <r:jQuery selector="#listaSimple tr:odd" query="addClass('odd-row')" />
                        <r:jQuery selector="#listaSimple tr:even" query="addClass('even-row')" />
                        <r:jQuery selector="#listaSimple tr" query="mouseover(function(){jQuery(this).addClass('active-row')})"/>
                        <r:jQuery selector="#listaSimple tr" query="mouseout(function(){jQuery(this).removeClass('active-row')})"/>
                    </r:panel>
                </h:form>
            </h:panelGrid>
        </center>
    </ui:define>

</ui:composition>
